<!DOCTYPE html>
<!--
  Copyright 2016 Google Inc.

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
-->
<html>
  <head>
    <meta charset="utf-8">
    <title>Layout Grid - Material Components</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
    <link rel="stylesheet" href="/assets/layout-grid.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <style>
      .demo-grid {
        background-color: #DDDDDD;
        margin-bottom: 32px;
      }

      .demo-cell {
        box-sizing: border-box;
        background-color: #666666;
        height: 200px;
        padding: 8px;
        color: white;

        font-size: 1.5em;
      }

      .demo-parent-cell {
        position: relative;
        background-color: #aaaaaa;
      }

      .demo-parent-cell>span{
        position: absolute;
        top: 8px;
        left: 8px;
        font-size: 1.5em;
        color: white;
      }

      .demo-child-cell {
        position: relative;
      }

      .demo-child-cell>span{
        position: absolute;
        bottom: 8px;
        right: 8px;
        color: #ddd;
      }

      .demo-grid.max-width {
        max-width: 1280px;
      }

      .demo-grid-legend {
        margin: 16px 0 8px 0;
      }

      .demo-ruler {
        position: fixed;
        display: flex;
        align-items: center;
        justify-content: center;
        bottom: 0;
        left: 0;
        height: 20px;
        width: 100%;
        margin: 0;
        background: black;
        color: white;
      }

      .demo-controls {
        display: none;
        margin-bottom: 8px;
      }
      .demo-warning::after {
        content: "This browser does not support custom properties, so margins and gutters cannot be changed at runtime.";
      }

      @supports (--foo: green) {
        .demo-controls {
          display: block;
        }

        .demo-warning::after {
          content: "";
        }
      }

      .examples {
        margin: 24px;
      }

      .hero .demo-grid {
        min-width: 360px;
      }

      .hero .demo-cell {
        height: 60px;
      }
    </style>
  </head>
  <body class="mdc-typography">
    <header class="mdc-toolbar mdc-toolbar--fixed">
      <div class="mdc-toolbar__row">
        <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
          <a href="/" class="catalog-back mdc-toolbar__menu-icon"><i class="material-icons">&#xE5C4;</i></a>
          <span class="mdc-toolbar__title catalog-title">Layout Grid</span>
        </section>
      </div>
    </header>

    <main>
      <div class="mdc-toolbar-fixed-adjust"></div>
      <section class="hero">

        <div class="demo-grid mdc-layout-grid">
          <div class="mdc-layout-grid__inner">
            <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
            <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
            <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
          </div>
        </div>

      </section>

      <section class="examples">
        <h2 class="demo-grid-legend">Layout grid (in fluid container)</h2>
        <section id="layout-grid-in-fluid-container">
          <div class="mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Desktop Margin:
                  <select class="desktop-margin">
                    <option value="8px">8px</option>
                    <option value="16px">16px</option>
                    <option value="24px" selected>24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Desktop Gutter:
                  <select class="desktop-gutter">
                    <option value="8px">8px</option>
                    <option value="16px">16px</option>
                    <option value="24px" selected>24px</option>
                    <option value="40px">40px</option>
                  </select>
                </div>
              </div>
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Tablet Margin:
                  <select class="tablet-margin">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Tablet Gutter:
                  <select class="tablet-gutter">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>
                </div>
              </div>
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Phone Margin:
                  <select class="phone-margin">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Phone Gutter:
                  <select class="phone-gutter">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>
                </div>
              </div>
            </div>
          </div>

          <div class="demo-warning"></div>

          <div class="demo-grid-legend">Grid of default wide (4 columns) items</div>
          <div class="demo-grid mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell">4</div>
              <div class="demo-cell mdc-layout-grid__cell">4</div>
              <div class="demo-cell mdc-layout-grid__cell">4</div>
            </div>
          </div>

          <div class="demo-grid-legend">Grid of 1 column wide items</div>
          <div class="demo-grid mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1">1</div>
            </div>
          </div>

          <div class="demo-grid-legend">Grid of differently sized items</div>
          <div class="demo-grid mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-6">6</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-2">2</div>
            </div>
          </div>

          <div class="demo-grid-legend">Grid of items with tweaks at different screen sizes</div>
          <div class="demo-grid mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-6 mdc-layout-grid__cell--span-8-tablet">6 (8 tablet)</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4 mdc-layout-grid__cell--span-6-tablet">4 (6 tablet)</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--span-4-phone">2 (4 phone)</div>
            </div>
          </div>

          <div class="demo-grid-legend">Grid nested within parent grid cell</div>
          <div class="demo-grid mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="demo-parent-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
                <div class="mdc-layout-grid__inner">
                  <div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
                    <span>Child 4</span>
                  </div>
                  <div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
                    <span>Child 4</span>
                  </div>
                  <div class="demo-child-cell demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">
                    <span>Child 4</span>
                  </div>
                </div>
                <span>Parent 4</span>
              </div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4">4</div>
            </div>
          </div>

          <h3 class="demo-grid-legend">Grid with max width</h3>
          <div class="demo-grid-legend">Grid with max width (1280px) and center alignment by default</div>
          <div class="demo-grid mdc-layout-grid max-width">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
            </div>
          </div>

          <div class="demo-grid-legend">Grid with max width (1280px) and left alignment</div>
          <div class="demo-grid mdc-layout-grid max-width mdc-layout-grid--align-left">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
            </div>
          </div>
        </section>

        <h2 class="demo-grid-legend">Fixed column width layout grid</h2>
        <section id="fixed-column-width-layout-grid">
          <div class="mdc-layout-grid">
            <div class="mdc-layout-grid__inner">
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Desktop Margin:
                  <select class="desktop-margin">
                    <option value="8px">8px</option>
                    <option value="16px">16px</option>
                    <option value="24px" selected>24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Desktop Gutter:
                  <select class="desktop-gutter">
                    <option value="8px">8px</option>
                    <option value="16px">16px</option>
                    <option value="24px" selected>24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Desktop Column Width:
                  <select class="desktop-column-width">
                    <option value="72px" selected>72px</option>
                    <option value="84px">84px</option>
                  </select>
                </div>
              </div>
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Tablet Margin:
                  <select class="tablet-margin">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Tablet Gutter:
                  <select class="tablet-gutter">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Tablet Column Width:
                  <select class="tablet-column-width">
                    <option value="72px" selected>72px</option>
                    <option value="84px">84px</option>
                  </select>
                </div>
              </div>
              <div class="mdc-layout-grid__cell">
                <div class="demo-controls">
                  Phone Margin:
                  <select class="phone-margin">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Phone Gutter:
                  <select class="phone-gutter">
                    <option value="8px">8px</option>
                    <option value="16px" selected>16px</option>
                    <option value="24px">24px</option>
                    <option value="40px">40px</option>
                  </select>

                  <br>

                  Phone Column Width:
                  <select class="phone-column-width">
                    <option value="72px" >72px</option>
                    <option value="84px">84px</option>
                  </select>
                </div>
              </div>
            </div>
          </div>
          <div class="demo-grid-legend">Fixed column width layout grid and center alignment by default</div>
          <div class="demo-grid mdc-layout-grid mdc-layout-grid--fixed-column-width">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
            </div>
          </div>

          <div class="demo-grid-legend">Fixed column width layout grid and right alignment</div>
          <div class="demo-grid mdc-layout-grid mdc-layout-grid--fixed-column-width mdc-layout-grid--align-right">
            <div class="mdc-layout-grid__inner">
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
              <div class="demo-cell mdc-layout-grid__cell mdc-layout-grid__cell--span-1"></div>
            </div>
          </div>
        </section>

        <div class="demo-ruler"><div id="current"></div></div>
      </section>
    </main>

    <script>
      (function() {
        var fluidContainerSection = document.getElementById('layout-grid-in-fluid-container');
        var fixedWidthSection = document.getElementById('fixed-column-width-layout-grid');

        var marginSelectDesktopFluid = fluidContainerSection.querySelector('.desktop-margin');
        marginSelectDesktopFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-desktop', marginSelectDesktopFluid.value);
        });

        var gutterSelectDesktopFluid = fluidContainerSection.querySelector('.desktop-gutter');
        gutterSelectDesktopFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-desktop', gutterSelectDesktopFluid.value);
        });

        var marginSelectTabletFluid = fluidContainerSection.querySelector('.tablet-margin');
        marginSelectTabletFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-tablet', marginSelectTabletFluid.value);
        });

        var gutterSelectTabletFluid = fluidContainerSection.querySelector('.tablet-gutter');
        gutterSelectTabletFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-tablet', gutterSelectTabletFluid.value);
        });

        var marginSelectPhoneFluid = fluidContainerSection.querySelector('.phone-margin');
        marginSelectPhoneFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-margin-phone', marginSelectPhoneFluid.value);
        });

        var gutterSelectPhoneFluid = fluidContainerSection.querySelector('.phone-gutter');
        gutterSelectPhoneFluid.addEventListener('change', function() {
          fluidContainerSection.style.setProperty('--mdc-layout-grid-gutter-phone', gutterSelectPhoneFluid.value);
        });

        var marginSelectDesktopFixed = fixedWidthSection.querySelector('.desktop-margin');
        marginSelectDesktopFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-desktop', marginSelectDesktopFixed.value);
        });

        var gutterSelectDesktopFixed = fixedWidthSection.querySelector('.desktop-gutter');
        gutterSelectDesktopFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-desktop', gutterSelectDesktopFixed.value);
        });

        var columnWidthSelectDesktopFixed = document.querySelector('.desktop-column-width');
        columnWidthSelectDesktopFixed.addEventListener('change', function() {
          document.documentElement.style.setProperty('--mdc-layout-grid-column-width-desktop', columnWidthSelectDesktopFixed.value);
        });

        var marginSelectTabletFixed = fixedWidthSection.querySelector('.tablet-margin');
        marginSelectTabletFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-tablet', marginSelectTabletFixed.value);
        });

        var gutterSelectTabletFixed = fixedWidthSection.querySelector('.tablet-gutter');
        gutterSelectTabletFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-tablet', gutterSelectTabletFixed.value);
        });

        var columnWidthSelectTabletFixed = document.querySelector('.tablet-column-width');
        columnWidthSelectTabletFixed.addEventListener('change', function() {
          document.documentElement.style.setProperty('--mdc-layout-grid-column-width-tablet', columnWidthSelectTabletFixed.value);
        });

        var marginSelectPhoneFixed = fixedWidthSection.querySelector('.phone-margin');
        marginSelectPhoneFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-margin-phone', marginSelectPhoneFixed.value);
        });

        var gutterSelectPhoneFixed = fixedWidthSection.querySelector('.phone-gutter');
        gutterSelectPhoneFixed.addEventListener('change', function() {
          fixedWidthSection.style.setProperty('--mdc-layout-grid-gutter-phone', gutterSelectPhoneFixed.value);
        });

        var columnWidthSelectPhoneFixed = document.querySelector('.phone-column-width');
        columnWidthSelectPhoneFixed.addEventListener('change', function() {
          document.documentElement.style.setProperty('--mdc-layout-grid-column-width-phone', columnWidthSelectPhoneFixed.value);
        });

        var current = document.querySelector('#current');
        var update = function() {
          var size = '(phone)';
          if (window.innerWidth >= 840) {
            size = '(desktop)';
          } else if (window.innerWidth >= 480) {
            size = '(tablet)';
          }
          current.textContent = window.innerWidth + 'px ' + size;
        };
        window.addEventListener('resize', update);
        update();
      })();
    </script>
  </body>
</html>
